// app.js
const config = require("./config")
App({
  globalData: {
    pageSize: 10,
    appName: config.appName,
    imgServer: config.imgServer,
    isLogin: false,
    token: "token",
    userInfo: {},
    logiRole: {},
    stateMap: {
      SCHEDULING: '调度中',
      SCHEDULED: '已接受',
      BEREFUSED: '已拒绝',
      TRANSPORTING: '运输中',
      TRANSABORT: '配送中止',
      COMPLETED: '已完成'
    }
  },
  checkLogin(){
    if(this.globalData.isLogin){
      return;
    }
    var token = wx.getStorageSync("token");
    if(token === '' || token === null || typeof token === 'undefined' || token === 'token'){
      this.globalData.token = null;
      this.globalData.isLogin = false;
      console.error("token失效")
      wx.redirectTo({
        url: '/pages/login/login',
      })
    }else{
      this.globalData.userInfo = wx.getStorageSync('userInfo')
      this.globalData.logiRole = wx.getStorageSync('logiRole')
      this.globalData.token = token;
      this.globalData.isLogin = true;
    }
  },
  onLaunch: function () {
  },
  onShow: function(){
  }
})
